package cn.kgm.annotation.test2;

import lombok.extern.java.Log;

import java.lang.reflect.Method;
import java.util.Objects;

/**
 * @Author: Kappi
 * @Date: 2022-7-25 16:50
 * @ClassName: TestController
 * @Description: cn.kgm.annotation.test2 TestController
 * @Version 1.8
 */
@Log
@MyAnnotation(message = "你好，我是你的爹")
public class TestController {

    public static void main(String[] args) {
        Class<TestController> testControllerClass = TestController.class;
        MyAnnotation annotation = testControllerClass.getAnnotation(MyAnnotation.class);
        log.info(annotation.message());
        aa();
    }

    @MyAnnotation(message = "您好，我是你的儿")
    public static void aa() {
        final Class<TestController> testControllerClass = TestController.class;
        Method[] methods = testControllerClass.getMethods();
        for (Method method : methods) {
            if (Objects.nonNull(method) && method.getName().equals("aa")) {
                MyAnnotation annotation = method.getAnnotation(MyAnnotation.class);
                log.info(annotation.message());
            }
        }
    }
}
